<?php
// +----------------------------------------------------------------------
// | RXThinkCMF_EVTP5.1_PRO前后端分离旗舰版框架 [ RXThinkCMF ]
// +----------------------------------------------------------------------
// | 版权所有 2018~2021 南京RXThinkCMF研发中心
// +----------------------------------------------------------------------
// | 官方网站: http://www.rxthink.cn
// +----------------------------------------------------------------------
// | 作者: ZhangXuanNeng <rxthinkcmf@163.com>
// +----------------------------------------------------------------------
// | 免责声明:
// | 本软件框架禁止任何单位和个人用于任何违法、侵害他人合法利益等恶意的行为，禁止用于任何违
// | 反我国法律法规的一切平台研发，任何单位和个人使用本软件框架用于产品研发而产生的任何意外
// | 、疏忽、合约毁坏、诽谤、版权或知识产权侵犯及其造成的损失 (包括但不限于直接、间接、附带
// | 或衍生的损失等)，本团队不承担任何法律责任。本软件框架只能用于公司和个人内部的法律所允
// | 许的合法合规的软件产品研发，详细声明内容请阅读《框架免责声明》附件；
// +----------------------------------------------------------------------

namespace app\admin\controller;

use app\admin\service\SettlementPreService;
use app\common\controller\Export;

/**
 * 预结算单-控制器
 * @author ZhangXuanNeng
 * @since 2024/01/16
 * Class Settlementpre
 * @package app\admin\controller
 */
class Settlementpre extends Backend
{
    /**
     * 初始化
     * @author ZhangXuanNeng
     * @since 2020/11/19
     */
    protected function initialize()
    {
        parent::initialize(); // TODO: Change the autogenerated stub
        $this->service = new SettlementPreService();
    }
    // 修改分成比例
    public function updateProportion(){
        $result = $this->service->updateProportion();
        return $this->jsonReturn($result);
    }
    // 导入事件金额
    public function importEvent(){
        $result = $this->service->importEvent();
        return $this->jsonReturn($result);
    }
    // 结算前计算结算信息
    public function getSettlement(){
        $result = $this->service->getSettlement();
        return $this->jsonReturn($result);
    }
    // 结算
    public function setSettlement(){
        $result = $this->service->setSettlement();
        return $this->jsonReturn($result);
    }
    // 重新生成预结算单
    public function setSettlementPre(){
        $result = $this->service->setSettlementPre();
        return $this->jsonReturn($result);
    }
    // 自动结算导入
    public function importQueue(){
        $result = $this->service->importQueue();
        return $this->jsonReturn($result);
    }
    // 导出
    public function export(){
        $param = request()->param();
        // 查询条件
        $map = [];
        if(isset($param['promote_1_id']) && !empty($param['promote_1_id'])){
            $map[] = ['promote_1_id','=',$param['promote_1_id']];
        }
        if(isset($param['promote_id']) && !empty($param['promote_id'])){
            $map[] = ['promote_id','=',$param['promote_id']];
        }
        if(isset($param['package_id']) && !empty($param['package_id'])){
            $map[] = ['package_id','=',$param['package_id']];
        }
        if(isset($param['status']) && !empty($param['status'])){
            $map[] = ['status','=',$param['status']];
        }
        if(isset($param['jies_type']) && !empty($param['jies_type'])){
            $map[] = ['jies_type','=',$param['jies_type']];
        }
        if(isset($param['record_date']) && !empty($param['record_date'])){
            $map[] = ['record_date','between time',$param['record_date']];
        }
        if(isset($param['settlement_time']) && !empty($param['settlement_time'])){
            $map[] = ['settlement_time','between time',$param['settlement_time']];
        }
        $Export = new Export();
        $Export->expUser(4,$map);
    }
}